#ifndef _CRAMBUILDER_H_
#define _CRAMBUILDER_H_
#include <QString>
#include <QTextStream>

class CramClass;

class CramBuilder
{
public:
    CramBuilder(const QString& name, int level = 0);
    virtual ~CramBuilder();

    virtual QString build();
    virtual CramClass* addClass(const QString& name, const QStringList& bases, const QString& doc) = 0;
    virtual void addFunction(const QString& name, const QStringList& args, const QString& doc, const QString& ret) = 0;

    CramBuilder &operator<<(const QString& str);
    CramBuilder &operator<<(const char* str);
    QString ident;
protected:
    QString formatDoc(const QString&, int level);
    QHash<QString, CramBuilder*> _blocks;
    QTextStream _stream;
    QString _name;
    int _level;
    QString _content;
};

class CramModule: public CramBuilder
{
public:
    CramModule(const QString& name);

    virtual CramClass* addClass(const QString& name, const QStringList& bases, const QString& doc);
    virtual void addFunction(const QString& name, const QStringList& args, const QString& doc, const QString& ret);
};

class CramClass: public CramBuilder
{
public:
    CramClass(const QString& name, int level, const QStringList& bases, const QString& doc);
    virtual CramClass* addClass(const QString& name, const QStringList& bases, const QString& doc);
    virtual void addFunction(const QString& name, const QStringList& args, const QString& doc, const QString& ret);
};

#endif
